package com.poetry.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.poetry.domain.po.History;
import com.poetry.domain.po.Search;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SearchMapper extends BaseMapper<Search> {
    @Select("SELECT sh.* " +
            "FROM search sh " +
            "WHERE sh.user_id = #{userId} " +
            "ORDER BY sh.viewed_at DESC " +
            "LIMIT #{limit}")
    List<Search> selectHistory(@Param("userId") Integer userId,
                                            @Param("limit") int limit);
}
